/*
 *  F6.h
 *  Genetski
 *
 *  Created by Srđan Rašić on 11/19/11.
 *
 */

#pragma once
#include "Function.h"
#include <utility>
#include <cmath>

class F6 : public Function {
public:
	double square_vec_sum(const std::vector<double> vec) const {
		double sum = 0.0;
		
		for (unsigned int i = 0; i < vec.size(); i++)
			sum += vec[i]*vec[i];
		
		return sum;
	}
	
	virtual double operator() (std::vector<double> vec) const {
		return 0.5 - ( pow(sin(pow(square_vec_sum(vec), 0.5)), 2.0) - 0.5) / pow((1.0 + 0.001 * square_vec_sum(vec)), 2.0);
	}
	
	virtual std::pair<double, double> Domain() const {
		return std::make_pair(-1000, 1000);
	}
	
	virtual unsigned int Dimensions() const {
		return 1;
	}
};